<?php /* Smarty version 2.6.13, created on 2006-11-04 17:21:26
         compiled from file:C:%5Cdev%5Cxampp%5Chtdocs%5Cprojects%5Cbaj%5Csrc%5Cinclude%5Csnippets%5Csibling/tpl/sibling.tpl.php */ ?>

<?php echo '
<script language=javascript>
<!--
    function selectAll(flag)
    {
        var f = document.forms[\'sibling_form\'];
        for(i=0; i<f.elements.length; i++){
            if(f.elements[i].name == "chbx[]"){
                f.elements[i].checked = flag
            }
        }// for
    }
    function isblank(field) {
        var field = \'';  echo $this->_tpl_vars['insert_list_str'];  echo '\';
        var mega = \'';  echo $this->_tpl_vars['res_folder_str'];  echo '\';
        
        var f = document.forms[\'sibling_form\'];
        var chbx_flag = 0;
        var count_chbx = 0;
        for(i=0; i<f.elements.length; i++){
            if(f.elements[i].name == "chbx[]"){
                count_chbx ++;
                if(f.elements[i].checked){
                    chbx_flag ++;
                    
                }
            }
        }
        
        var a_name = "";
        var a_action = "";
        var str_inner = "";
        switch(document.getElementById(\'sibling_action\').value){
            case "swap":
                if(chbx_flag<2){
                    alert("Please check at least two items.");
                    a_name = -1;
                }else{
                    a_name = "Swap Items";
                    a_action = "swap";
                }
                break;
            // ==================  insert_after ==================
            case "insert_after":
                if(chbx_flag<1){
                    alert("Please check at least one item.");
                    a_name = -1;
                }else{
                    /// we get params
                    in_params = field.split("||");
                    var i_p = new Array();
                    for(i= 0; i <in_params.length;i++){
                        i_p[i] = in_params[i].split("|");
                    }
                    
                    a_name = "Insert Selected After";
                    a_action = "insert_after";
                        str_inner =str_inner+ "<select name=\'sibling_count\'>";
                        for(i=1; i<count_chbx+1 ; i++){
                            if(i_p[i-1])
                            str_inner += "<option value=\'"+ i_p[i-1][1]+"\'>"+ i_p[i-1][1]+" - "+i_p[i-1][2] +"</option>";
                        }
                        str_inner +="</select>&nbsp;";
                }
                break;
            // ==================  insert_before ==================
            case "insert_before":
                if(chbx_flag<1){
                    alert("Please check at least one item.");
                    a_name = -1;
                }else{
                    /// we get params
                    in_params = field.split("||");
                    var i_p = new Array();
                    for(i= 0; i <in_params.length;i++){
                        i_p[i] = in_params[i].split("|");
                    }
                    
                    a_name = "Insert Before After";
                    a_action = "insert_before";
                        str_inner =str_inner+ "<select name=\'sibling_count\'>";
                        for(i=1; i<count_chbx+1 ; i++){
                            str_inner += "<option value=\'"+ i_p[i-1][1]+"\'>"+ i_p[i-1][1]+" - "+i_p[i-1][2] +"</option>";
                        }
                        str_inner +="</select>&nbsp;";
                }
                break;
            // ==================  insert_before ==================
            case "sibling_delete":
                if(chbx_flag<1){
                    alert("Please check at least one item.");
                    a_name = -1;
                }else{
                    a_name = "Delete Items";
                    a_action = "sibling_delete";
                }
                break;
            // ==================  move_to_folder ==================
            case "move_to_folder":
                if(chbx_flag<1){
                    alert("Please check at least one item.");
                    a_name = -1;
                }else{
                    a_name = "Move to Folder";
                    a_action = "move_to_folder";
                        /// we get params
                        //alert(mega);
                        in_params = mega.split("||");
                        var i_p = new Array();
                        for(i= 0; i <in_params.length;i++){
                            i_p[i] = in_params[i].split("|");
                        }
                        //alert(i_p.length+  " " +count_chbx ); 
                        str_inner =str_inner+ "<select name=\'sibling_count\'>";
                        for(i=1; i<in_params.length +1 ; i++){
                            str_inner += "<option value=\'"+ i_p[i-1][0]+"\'>"+ i_p[i-1][1]+"</option>";
                        }
                        str_inner +="</select>&nbsp;";
                }
                break;
            // ==================  -1  ==================
            
            case "-1":
                a_name="-1";
        }
        
        if(a_name != "-1")
         str_inner += "<input type=\'button\' value=\'"+a_name+"\' class=\'button\' onclick=\'getConfirm()\'/> <input type=\'hidden\' name=\'action\' value=\'"+a_action+"\'/>";
        else{ 
            str_inner = "";
            document.getElementById(\'sibling_action\').selectedIndex = 0;
        }
        document.getElementById(\'sibling_div\').innerHTML= str_inner;
    }
    
    function getConfirm()
    {
        var mes = window.confirm("Click OK to process action. Click Cancel to cancel action.");
        if (mes) {
            frm = document.forms[\'sibling_form\'].submit();
        } else  window.alert("You cancel action!");
    }   
// -->
</script>
'; ?>

<div>
<table>
    <tr>
        <td>
            <a href="" onclick="selectAll(true);return false;" >Select&nbsp;All</a>&nbsp;/&nbsp;<a href="" onclick="selectAll(false);return false;">Unselect&nbsp;All</a>
        </td>
    </tr>
    <tr>
        <td>
        <select name="sibling_action" id="sibling_action" onchange="isblank()">
            <option value="-1"><?php echo $this->_tpl_vars['select_text']; ?>
</option>
            <?php $_from = $this->_tpl_vars['action_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['item']):
?>
            <option value="<?php echo $this->_tpl_vars['key']; ?>
"><?php echo $this->_tpl_vars['item']; ?>
</option>
            <?php endforeach; else: ?>
            <option value="-1">Empty Action List</option>
            <?php endif; unset($_from); ?>
        </select>
        </td>
        <td>
            <div id="sibling_div" style="sborder:1px solid blue;"></div>
        </td>
    </tr>
</table>
</div>